<template>
	<div class="selectDep">
		<el-dialog title="请选择实验室" :visible.sync="addVisible" width="55%" :close-on-click-modal='false' :show-close="false" :close-on-press-escape="false"
		 :modal-append-to-body='false'  v-loading="loading"
    element-loading-text="实验室数据初始化中..."
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.6)">
			<el-table :data="labData" size="mini" ref="standardTable" height="280" @cell-click="clickcell">
				<el-table-column property="name" label="实验室名称" fixed min-width="60px">
				</el-table-column>
				<el-table-column property="groupName" label="组织" fixed min-width="60px">
				</el-table-column>
			</el-table>
		</el-dialog>
		<!--<el-dialog
		  	:visible.sync="labNull"
		  	width="55%"
		  	:close-on-click-modal='false'
		  	:show-close="false"
		  	:close-on-press-escape="false"
		  	:modal-append-to-body='false'
			class="labNull">
			<div style="height: 190px;text-align: center;line-height: 190px;">
				{{errdescription}}
			</div>
			<span slot="footer" class="dialog-footer">
			    <el-button type="primary" size="mini" @click="goback">返回</el-button>
			</span>
		</el-dialog>-->
	</div>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		name: "selectDep",
		data() {
			return {
			  flag: true,
				dialogVisible: false,
				// labData:[],
				haveLab: false,
				labNull: false,
				errdescription: '',
        loading:false,
			}
		},
		props: ['labData', 'addVisible'],
		mounted() {
			// this.getlabAuth();

		},
		methods: {
			// getlabAuth(){
			// 	this.$http({
			// 		 apiUrl: 'login/getlabAuth.htm',
			// 	     method: 'get',
			// 	}).then(res=>{
			// 		if(res.code == 0){
			// 				this.dialogVisible =true;
			// 				this.labData = res.data;

			// 		}else if(res.code == 11202){
			// 			this.$router.push('/')
			// 		}

			// 	})
			// },
			clickcell(val) {
			  if(this.flag) {
          this.loading = true;
          this.$set(this, 'flag', false)
          this.$http({
            apiUrl: 'login/chooselab.htm',
            method: 'post',
            params: { id: val.id,mark:val.mark },
            isJson: false
          }).then(res => {
            this.loading = false;
            if (res.code === 0) {
              
              sessionStorage.setItem("defaultlabData", JSON.stringify(val));
              // console.log(val,res.data)
              // global.isSameLab = val.id;
              this.$router.push('/shuisi')
              this.$store.commit('changenowpage', 'homePage');
              this.$store.state.menuName = '';
              this.$store.state.pageName = '';
              this.$store.dispatch('dogetDictionary')

            }

          })
          setTimeout(() => {
            this.$set(this, 'flag', true)
          }, 500)
        }
			},
			goback() {
				this.$router.push('/')
			}

		},
		computed: {
			...mapState(['pageName', 'menuName']),
		},
	}

</script>

<style>
	.selectDep {}

	.selectDep .el-dialog__header {
		padding: 10px;
		text-align: center;
	}

	.selectDep .el-dialog__header .el-dialog__title {
		font-size: 16px;
	}

	.selectDep .el-dialog__body {
		padding: 20px 10px;
	}

	.selectDep .el-table th,
	.el-table td {
		text-align: center !important;
	}
	.selectDep  .el-dialog__wrapper{
		background: #ccc;
	}

	/*.selectDep .v-modal {
		opacity: 1;
		filter: alpha(opacity=50);
		-moz-opacity: 0.5;
		-khtml-opacity: 0.5;
		opacity: 0.5;
		background: rgba(0, 0, 0, 0.3);
	}*/

	.selectDep .labNull .el-dialog__header {
		padding: 0 !important;
	}

	.selectDep .labNull .el-dialog__footer {
		text-align: center !important;
	}
</style>
